home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / VCal / Entry.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  4.7 KB  |  163 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #ifndef _ENTRY_
  18. #define _ENTRY_
  19.  
  20. #include <stdio.h>
  21. #include <malloc.h>
  22. #include <string.h>
  23.  
  24. #define MAX_ALARM_NOTIFICATIONS        64
  25. #define ALL_NOTIFICATIONS        -1
  26.  
  27. enum EntryKind { E_none,
  28.          E_single,
  29.          E_repeatDaily,
  30.          E_repeatWeekDaily,
  31.          E_repeatWeekly,
  32.          E_repeatBiWeekly,
  33.          E_repeatMonthlyDate,
  34.          E_repeatMonthlyDay,
  35.          E_repeatMonthlyDateEnd,
  36.          E_repeatMonthlyDayEnd,
  37.          E_repeatYearly };
  38.  
  39. class Entry;
  40.  
  41. typedef struct {
  42.   EntryKind kind;
  43.   char *string;
  44. } EntryKindInfo;
  45.  
  46. typedef struct {
  47.   Entry *entry;
  48.   void *alarm;
  49.   void *data;
  50. } EntryAlarmInfo;
  51.  
  52. extern const EntryKindInfo entryKindList[];
  53. extern const int entryKindCount;
  54.  
  55. class Entry {
  56. public:
  57.   Entry();
  58.   ~Entry();
  59.  
  60.   int day() { return _day; }
  61.   int month() { return _month; }
  62.   int year() { return _year; }
  63.   int start() { return _start; }
  64.   int length() { return _length; }
  65.   void setTime(int start, int length)
  66.     { _start = start; _length = length; }
  67.  
  68.   EntryKind kind() { return _kind; }
  69.   void setKind(EntryKind k) { _kind = k; }
  70.   int repeating() { return (_kind != E_none && _kind != E_single);}
  71.  
  72.   int notifyPopup() { return _notifyPopup; }
  73.   void setNotifyPopup(int v) { _notifyPopup = v; }
  74.   int notifyBell() { return _notifyBell; }
  75.   void setNotifyBell(int v) { _notifyBell = v; }
  76.   int notifyMail() { return _notifyMail; }
  77.   void setNotifyMail(int v) { _notifyMail = v; }
  78.   char *notifyCommand() { return _notifyCommand; }
  79.   void setNotifyCommand(char *v);
  80.  
  81.   int alarmFired(int alarmIndex) { return _alarmFired[alarmIndex]; }
  82.   void setAlarmFired(int v, int alarmIndex);
  83.   int annotate() { return _annotate; }
  84.   void setAnnotate(int a) { _annotate = a; }
  85.   char *alarmAdvance() { return _advance; }
  86.   int setAlarmAdvance(char *str);
  87.  
  88.   char *text() { return _text; }
  89.   int setText(char *t);
  90.  
  91.   Entry *next() { return _next; }
  92.   void setNext(Entry *d) { _next = d; }
  93.  
  94.   void *data() { return _data; }
  95.   void setData(void *d) { _data = d; }
  96.   void *snoozeData() { return _snoozeData; }
  97.   void setSnoozeData(void *d) { _snoozeData = d; }
  98.  
  99.   EntryAlarmInfo *alarmInfo() { return _alarmInfo; }
  100.  
  101.   int alarmApplies(int time, int *alarmIndex,
  102.            int unfiredOnly = 1);
  103.   int alarmApplies(int day, int month, int year, int *alarmIndex,
  104.            int *matchDay, int *matchMonth, int *matchYear,
  105.            int unfiredOnly = 1);
  106.  
  107.   virtual void setDate(int day, int month, int year);
  108.   virtual int readEntry(FILE *fd, int version);
  109.   virtual void writeEntry(FILE *fd, int annotate);
  110.   virtual void printEntry(FILE *fd, int clock24);
  111.   virtual int daysInAdvance(int days, int day, int month, int year,
  112.                 int *matchDay, int *matchMonth, int *matchYear);
  113.  
  114. protected:
  115.   char *reformatAdvanceString(char *str);
  116.   int parseAdvance(char *str, char **remainder);
  117.  
  118.   int _day, _month, _year;
  119.   int _start, _length;
  120.   EntryKind _kind;
  121.   int _notifyPopup, _notifyBell, _notifyMail;
  122.   char *_notifyCommand;
  123.   int _alarmFired[MAX_ALARM_NOTIFICATIONS];
  124.   Entry *_next, *_next2;
  125.   char *_text;
  126.   int _annotate;
  127.   char *_advance;
  128.   void *_data, *_snoozeData;
  129.   EntryAlarmInfo *_alarmInfo;
  130. };
  131.  
  132. class RepeatingEntry : public Entry {
  133. public:
  134.   RepeatingEntry();
  135.   ~RepeatingEntry();
  136.  
  137.   int repeatEndDay() { return _repeatEndDay; }
  138.   int repeatEndMonth() { return _repeatEndMonth; }
  139.   int repeatEndYear() { return _repeatEndYear; }
  140.   void setRepeatEnd(int day, int month, int year)
  141.     { _repeatEndDay = day; _repeatEndMonth = month; _repeatEndYear = year; }
  142.   int repeatApplies(int day, int month, int year);
  143.   int weekday() { return _weekday; }
  144.  
  145.   RepeatingEntry *next() { return (RepeatingEntry *) _next; }
  146.   void setNext(RepeatingEntry *d) { _next = d; }
  147.  
  148.   virtual void setDate(int day, int month, int year);
  149.   virtual int readEntry(FILE *fd, int version);
  150.   virtual void writeEntry(FILE *fd, int annotate);
  151.   virtual int daysInAdvance(int days, int day, int month, int year,
  152.                 int *matchDay, int *matchMonth, int *matchYear);
  153.   virtual int readDate(FILE *fd, int version);
  154.   virtual void writeDate(FILE *fd, int annotate);
  155.  
  156. protected:
  157.   int _repeatEndDay, _repeatEndMonth, _repeatEndYear;
  158.   RepeatingEntry *_nextRepeat;
  159.   int _weekday;
  160. };
  161.  
  162. #endif
  163.